package ncku.account.unitTest;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;

import ncku.account.data.SubTransaction;
import ncku.account.data.SubTransactionList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class SubTransactionListTest {
	SubTransactionList astl;
       
	@Before
    public void setUp(){
		astl = new SubTransactionList();
    }
	@After
    public void tearDown(){
		astl = null;
    }
    @Test
    public void test(){
    	
    	//test addSubTrans & getSubTrans
    	astl.addSubTrans("test",1000);
    	assertEquals(1000,astl.getSubTrans(0).getSubAmount());
    	assertEquals("test",astl.getSubTrans(0).getSubDescription());
    	
    	//test editSubTrans
    	astl.editSubTrans(0,"test2",1001);
    	assertEquals(1001,astl.getSubTrans(0).getSubAmount());
    	assertEquals("test2",astl.getSubTrans(0).getSubDescription());
    	  	
    	//test getArrayListSubTrans
    	ArrayList<SubTransaction> subTransactions = null;
    	subTransactions.add(astl.getSubTrans(0));
    	assertEquals(subTransactions,astl.getArrayListSubTrans());
    	
    	//test getSize
    	assertEquals(1,astl.getSize());
    	
    	//test deleteSubTrans
    	astl.deleteSubTrans(0);
    	assertEquals(null,astl.getArrayListSubTrans());
    	
    	
    }

}